<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basepath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>选择加入公司 </title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <link href="<%=basepath%>css/index.css" rel="stylesheet" type="text/css">
    <link href="<%=basepath%>css/company.css" rel="stylesheet" type="text/css">
    <script src="<%=basepath%>js/jquery-1.8.3.min.js"></script>
    <script src="<%=basepath%>js/layer/layer.js"></script>
</head>
<body>
<div class="viewport">
    <div class="header">
       <div class="header-1">
           <a href="javascrpt:void(0)" id="join" class="header-2">
              <span id="account" class="account">${empty user.realName ? '' : user.realName}</span>&nbsp;&nbsp;<span id="deptName" class="deptName">${user.departmentName}</span>
           </a>
           <a href="/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=company&prefix=3g_company&entrance=yes" class="back" id="back">返回</a>
           <span class="span-num">WYP12510</span>
       </div>
    </div>
    <div class="content m-top">
        <form method="post" id="myForm" action="/wape-web/api/core/centerService">
        <div class="content4-1">
            <div class="content4-1-1"><span style="font-size:16px;font-weight:bold;">请选择您要加入的公司</span><input type="submit" value="确认提交" class="input-1"></div>
        </div>
        <div class="content4-2">
        	<c:forEach var="cp" items="${cps}">
        		<div class="content4-2-1">
	                <span style="float:left;font-size:12px;" class="companyName">${cp.companyName}</span>
	                <span style="display:none;" class="companyId">${cp.companyId}</span>
	                <input type="radio" name="radio" class="radio" style="float:right;width:16px;height:16px;position:relative;top:12px;">
	            </div>
	            <div class="hr-2"></div>
        	</c:forEach>
        </div>
        <input type="hidden" name="companyName" id="companyName" />
        <input type="hidden" name="companyId" id="companyId" />
        <input type="hidden" name="serviceCode" value="MMZS131" />
        </form>
    </div>
</div>
</body>
<script type="text/javascript">
    /*错误提示*/
    $(function(){
        var error = "${requestScope.returnMsg}";
        if(error != "" && error != "成功!"){
            layer.msg(error,{shadeClose:true,shade:0.1,time:2000});
        }
    });
    /*radio*/
    $(function(){
    	$(".content4-2-1 .radio").click(function(){
    		var radio = $('.content4-2-1 .radio:radio:checked').val();
        	var companyName = $('.content4-2-1 .radio:radio:checked').siblings(".content4-2-1 .companyName").text();
        	var companyId = $('.content4-2-1 .radio:radio:checked').siblings(".content4-2-1 .companyId").text();
        	$("#companyName").val(companyName);
        	$("#companyId").val(companyId);
    	});
    });
    /*表单提交*/
    $(function(){
    	$("#myForm").submit(function(){
    		var radio = $('.content4-2-1 .radio:radio:checked').val();
    		var companyName = $("#companyName").val();
    		var companyId = $("#companyId").val();
    		if(radio == undefined || radio == ""){
    			layer.msg("请选择公司",{shadeClose:true,shade:0.1,time:2000});
                return false;
    		}
    		else if(companyName == undefined || companyName == ""){
    			layer.msg("未知异常，请刷新重试",{shadeClose:true,shade:0.1,time:2000});
                return false;
    		}
    		else if(companyId == undefined || companyId == ""){
    			layer.msg("未知异常，请刷新重试",{shadeClose:true,shade:0.1,time:2000});
                return false;
    		}
    		else{
    			layer.load();
    			setTimeout(function(){
              	  layer.closeAll();
              	  layer.msg("网络异常，请重新尝试！",{shadeClose:true,shade:0.1,time:2000});
              	}, 30000);
    		}
    	});
    });
</script>
</html>

